home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 6057 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  979 b 

  1. Path: ip-salem3-26.teleport.com!user
  2. From: dynamix@teleport.com (Steve Budrys)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: How to delete array of pointers?
  5. Date: Sat, 10 Feb 1996 16:29:25 -0800
  6. Organization: Dynamix Trading
  7. Message-ID: <dynamix-1002961629250001@ip-salem3-26.teleport.com>
  8. References: <4fgvsu$5q4@eng_ser1.erg.cuhk.hk>
  9. NNTP-Posting-Host: ip-salem3-26.teleport.com
  10.  
  11. In article <4fgvsu$5q4@eng_ser1.erg.cuhk.hk>, ywleung@cs.cuhk.hk (Marty
  12. McFly) wrote:
  13.  
  14. > If I write the following code in a function:
  15. >         int** ptr;
  16. >         ptr = new int*[1000];
  17. > Is this code means allocating 1000 integer pointers which is pointed by ptr?
  18. > And then somehow I assign integer variable to ptr[0], ptr[1], ... and so on.
  19. > So at the end of the function, how can I reclaim just those pointers?  The key
  20. > point is that those integer variable assigned to the pointers should not be 
  21. > deleted.
  22.  
  23. Simply
  24.    delete [] ptr;
  25.  
  26. The things to which they pointed will not be touched.
  27.